<template>
  <div class="photoinfo-container">
      <h3>{{photolist.title}}</h3>
      <p class="subtitle">
          <span>{{photolist.add_time | dateFormat}}</span>
          <span>点击次数：{{photolist.click}}次</span>
      </p>
      <hr>
      <!-- 缩略图区域 -->
      <img class="preview-img" v-for="(item) in list" :src="item.src" height="100" 
       :key="item.src"> 

      <!-- 图片区域 -->
      <div class="content" v-html="photolist.content"></div>
      <!-- 评论区子组件 -->
      <cmt-box :id="id"></cmt-box>
  </div>
</template>

<script>
import comment from "../subcomponents/comment.vue";
export default {
    data () {
        return{
            id: this.$route.params.id,
            photolist: {},
            list:[],
        };
    },
    created() {
        this.getphotoinfo();
        this.getthumimages();
    },
    methods: {
        getphotoinfo() {
          this.$http.get("api/getimageInfo/"+this.id).then(result=>{
              if(result.body.status === 0 ){
                  this.photolist = result.body.message[0]
              }
          })
        },
        getthumimages(){
            this.$http.get("api/getthumimages/"+this.id).then(result=>{
                if(result.body.status === 0 ){
                   result.body.message.forEach(item=>{
                       item.w = 600;
                       item.h = 400;
                   });
                 this.list = result.body.message;
                }
            })
        }
        
    },
    components: {
        "cmt-box": comment
    }
    
};
</script>


<style lang="scss" scoped>
    .photoinfo-container{
        padding: 3px;

        h3{
            font-size: 16px;
            color: rgb(30, 80, 219);
            text-align: center;
        }
        .subtitle{
            font-size: 12px;
            display: flex;
            justify-content: space-between;
        }
        .content{
            font-size: 13px;
            line-height: 30px;
        }
      
        img{
            margin: 10px;
            box-shadow: 0 0 8px #999;
        }
    }
</style>